    //
//  SC_BarChartVC.m
//  SCCharts
//
//  Created by Yang on 9/9/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "SC_BarChartVC.h"


@implementation SC_BarChartVC

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	dataArray = [[NSMutableArray alloc] init];
    [super viewDidLoad];
}

- (void)setFrame:(CGRect )rect {
	graphView = [[SC_BarChartView alloc] initWithFrame:rect];
	self.view = graphView;
	
}
- (void)setData:(NSArray *)array {
	[graphView setData:array];
}
- (void)setChartTitle:(NSString *)string {
	
	for (UIView *view in self.view.subviews) {
		if (view.tag == 10001) {
			[view removeFromSuperview];
		}
	}
	
	UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 480.0f, 30.0f)];
	label.backgroundColor = [UIColor clearColor];
	label.textAlignment = UITextAlignmentCenter;
	label.text = string;
	label.tag = 10001;
	[self.view addSubview:label];
	[label release];
	
	label = [[UILabel alloc] initWithFrame:CGRectMake(130.0f, 25.0f, 20.0f, 20.0f)];
	label.backgroundColor = [UIColor colorWithRed:251.0f/255.0f green:60.0f/255.0f blue:60.0f/255.0f alpha:1.0f];
	label.tag = 10001;
	[self.view addSubview:label];
	[label release];
	
	label = [[UILabel alloc] initWithFrame:CGRectMake(160.0f, 25.0f, 40.0f, 20.0f)];
	label.backgroundColor = [UIColor clearColor];
	label.font = [UIFont systemFontOfSize:13.0f];
	label.text = @"总数";
	label.tag = 10001;
	[self.view addSubview:label];
	[label release];
	
	label = [[UILabel alloc] initWithFrame:CGRectMake(210.0f, 25.0f, 20.0f, 20.0f)];
	label.backgroundColor = [UIColor colorWithRed:64.0f/255.0f green:64.0f/255.0f blue:255.0f/255.0f alpha:1.0f];
	label.tag = 10001;
	[self.view addSubview:label];
	[label release];
	
	
	label = [[UILabel alloc] initWithFrame:CGRectMake(240.0f, 25.0f, 40.0f, 20.0f)];
	label.backgroundColor = [UIColor clearColor];
	label.text = @"超标数";
	label.tag = 10001;
	label.font = [UIFont systemFontOfSize:13.0f];
	[self.view addSubview:label];
	[label release];
	
	label = [[UILabel alloc] initWithFrame:CGRectMake(290.0f, 25.0f, 20.0f, 20.0f)];
	label.backgroundColor = [UIColor colorWithRed:64.0f/255.0f green:255.0f/255.0f blue:64.0f/255.0f alpha:1.0f];
	label.tag = 10001;
	[self.view addSubview:label];
	[label release];
	
	label = [[UILabel alloc] initWithFrame:CGRectMake(320.0f, 25.0f, 80.0f, 20.0f)];
	label.backgroundColor = [UIColor clearColor];
	label.text = @"故障或停产";
	label.font = [UIFont systemFontOfSize:13.0f];
	label.tag = 10001;
	[self.view addSubview:label];
	[label release];
	
	
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
   // return (interfaceOrientation == UIInterfaceOrientationPortrait);
	if  ((interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) {
		[self dismissModalViewControllerAnimated:YES];
		return NO;
	}
	return YES;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[graphView release];
	[dataArray release];
    [super dealloc];
}


@end
